package org.sang.controller;

import org.sang.beans.RespBean;
import org.sang.beans.User;
import org.sang.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/zhanghu")
public class SystemUserController {

    @Autowired
    UserService userService;

    @RequestMapping("/{keywords}")
    public List<User> zhangHu(@PathVariable(value ="keywords",required = false) String keywords){
        System.out.println("keywords:"+keywords);
          List<User> list=userService.getUserByKeywords(keywords);
        return list;
    }

    @RequestMapping("/updUser")
    public RespBean updateUser( User user){
        if(userService.updateUser(user)==1){
            return RespBean.ok("更新成功");
        }
        return  RespBean.error("更新失败");
    }

    }
